using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;

namespace BUS
{
   public class tbloaisanphamBUS
    {
        static public string error = "";
        public static void Insert(tbloaispDTO lsp)
        {
            tbloaisanphamDAL tbloaisanphamDAL = new tbloaisanphamDAL();
            tbloaisanphamDAL.Insert(lsp);
        }
       public static void Update(tbloaispDTO lsp)
        {
            tbloaisanphamDAL tbloaisanphamDAL = new tbloaisanphamDAL();
            tbloaisanphamDAL.Update(lsp);
            error = tbloaisanphamDAL.error;
        }
        public static void Delete(int iD)
        {
            tbloaisanphamDAL tbloaisanphamDAL = new tbloaisanphamDAL();
            tbloaisanphamDAL.Delete(iD);
        }
        public static tbloaispDTOColection GET(string Where, int PageIndex, int PageSize,
                                        string OrderBy, string OrderDirection,
                                        out int TotalRecords)
        {
            tbloaisanphamDAL tbloaisanphamDAL = new tbloaisanphamDAL();
            return tbloaisanphamDAL.GET(Where, PageIndex, PageSize,
                            OrderBy, OrderDirection, out TotalRecords);
        }
       public static tbloaispDTOColection GETAll()
       {
           int t = 0;
           tbloaisanphamDAL tbloaisanphamDAL = new tbloaisanphamDAL();
           return tbloaisanphamDAL.GET("where 1=1", 0, 10, tbloaispDTOColumn.Tenloaisp.ToString(), "ASC", out t);
       }
       public static tbloaispDTO GetByID(int iD)
       {
           int t = 0;
           tbloaisanphamDAL tbloaisanphamDAL = new tbloaisanphamDAL();
           tbloaispDTOColection spcolect = tbloaisanphamDAL.GET("where " + tbloaispDTOColumn.Maloaisp.ToString() + " = " + iD.ToString(), 0, 0,
               tbloaispDTOColumn.Tenloaisp.ToString(), "ASC", out t);
           if (spcolect.Count == 1)
               return spcolect[0];
           return null;
       }
    }
}
